var a = getApp();

Page({
    data: {
        show1: !1,
        member_integral: 0,
        addressData: {},
        radio: "1",
        address: "",
        cash: "",
        address_id: "",
        integral_name: ""
    },
    onLoad: function(a) {
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    show1btn: function() {
        this.setData({
            show1: !0
        });
    },
    sureCash: function() {
        if (this.data.address) if (this.data.cash) if (Number(this.data.cash) < 0) wx.showToast({
            icon: "none",
            title: "输入的提现数额需大于0",
            duration: 1500
        }); else if (Number(this.data.cash) > Number(this.data.member_integral)) wx.showToast({
            icon: "none",
            title: "输入的提现数额超过已有的消费积分",
            duration: 1500
        }); else {
            var t = a.getNetAddresss("plugin.integral.Frontend.Modules.Integral.Controllers.integral-manual-cash-withdrawal.index");
            a._getNetWork({
                url: t,
                data: {
                    change_value: this.data.cash,
                    address_id: this.data.address_id
                },
                success: function(a) {
                    var t = a.data;
                    1 == t.result ? (wx.showToast({
                        icon: "none",
                        title: "提现成功",
                        duration: 1500
                    }), wx.navigateTo({
                        url: "/packageB/member/Integral_love/Integral_love"
                    })) : wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请输入提现数额",
            duration: 1500
        }); else wx.showToast({
            icon: "none",
            title: "请选择提现地址",
            duration: 1500
        });
    },
    cashBtn: function() {
        var a = e.detail.value;
        this.setData({
            name: a
        });
    },
    selectAddress: function(a) {
        var t = a.currentTarget.dataset.item;
        this.setData({
            address: t.address,
            address_id: t.id,
            show1: !1
        });
    },
    onClose: function(a) {
        this.setData({
            show1: !1
        });
    },
    toAdd: function(a) {
        wx.navigateTo({
            url: "/packageB/member/addressAdd/addressAdd"
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.integral.Frontend.Modules.Integral.Controllers.integral-manual-cash-withdrawal.pageIndex");
        a._getNetWork({
            url: e,
            data: {
                change_value: this.data.cash,
                address_id: this.data.address_id
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    integral_name: e.data.integral_name,
                    member_integral: e.data.member_integral,
                    addressData: e.data.addressData
                }), t.data.addressData.map(function(a, e, s) {
                    1 == a.is_default && t.setData({
                        radio: a.id,
                        address: a.address,
                        address_id: a.id
                    });
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            }
        });
    }
});